const path = require("path");
const router = require("koa-router")();

const fileUpload = require('../../utils/fileUpload')

router.post("/m1/upLoadImg",async ctx=>{
    let file = ctx.request.files.coverImg;
    console.log(66);
    var isUpload = Boolean(file.name.trim());
    /* 将本地图片放到服务器的static文件夹中 */
    if(isUpload){
        fileUpload(file)
        var avatar = ctx.origin +"/upLoad/"+path.basename(file.path);;
        console.log('avatar: ', avatar);
    }
    ctx.body={
        code:200
    }
});
module.exports = router;